package com.jjb.common.ability.adapter.service;

import java.util.HashMap;
import java.util.Map;

public interface IBusinessFactoryService<T, V> {

    Map<String, IBusinessService> businessServiceMap = new HashMap<>();

    default void addBusinessService(String businessWay, IBusinessService<T, V> businessService){
        this.businessServiceMap.put(businessWay, businessService);
    }

    default V execHandler(String businessWay, T data) {
        IBusinessService<T, V> businessService = businessServiceMap.get(businessWay);
        if ( businessServiceMap.get(businessWay) == null ) {
            throw new RuntimeException(businessWay+"不存在实现类");
        }

        return businessService.execHandler(data);
    }


}
